package com.edu.exam.enums.assessment;

/**
 * 比较范围枚举
 */
public enum ComparisonScope {
    LOCAL("LOCAL", "本地范围"),
    GLOBAL("GLOBAL", "全局范围"),
    PARTIAL("PARTIAL", "部分范围"),
    FULL("FULL", "完整范围"),
    SPECIFIC("SPECIFIC", "特定范围"),
    RELATED("RELATED", "相关范围"),
    ADJACENT("ADJACENT", "相邻范围"),
    CROSS_MODULE("CROSS_MODULE", "跨模块范围");

    private final String code;
    private final String description;

    ComparisonScope(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果代码无效
     */
    public static ComparisonScope fromCode(String code) {
        for (ComparisonScope scope : values()) {
            if (scope.getCode().equals(code)) {
                return scope;
            }
        }
        throw new IllegalArgumentException("Unknown ComparisonScope code: " + code);
    }

    /**
     * 从描述创建枚举实例
     *
     * @param description 枚举描述
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果描述无效
     */
    @Override
    public String toString() {
        return description;
    }
}